$(document).ready(function(){
	var validator = $("#frmMngProfile").validate({
		errorElement:'div',
		rules: {
			
			fname: {
				required:true,
				character:true
			},
			lname: {
				required:true,
				character:true
			},
			companyname: {
				required: true,
				remote: SITEROOT+'/modules/register/checkcompanynameexits.php?id='+$("#hidden_userid").val()
			},
			email: {
				required:true,
				email:true,
				remote:SITEROOT+'/modules/register/checkemailexits.php?id='+$("#hidden_userid").val()
			},
			mobno: {
				required:true,
        		minlength: 9,
				maxlength: 15
			},
			postcode: {
				required: true,
				minlength:3,
				//remote: SITEROOT+"/modules/register/checkpostalexits.php"			
			},
			state_id:{
			required: true
			},
			companydescription: {
				required: true
			},
			"catname[]":{
				required: true
			},
			"jobtype[]":{
				required: true
			},
			"state_id[]":{
				required: true
			}/*,
			about_me:{
				required: true
			},
			workhistory: {
				required: true
			},
			qual_accred: {
				required: true
			}*/
			
		
		},
		messages: {
			fname: {
				required:"Please enter first name",
				character:"Please enters only character"
			},
			lname: {
				required:"Please enter last name",
				character:"Please enters only character"
			},
			companyname: {
				required:"Please enter company name",
				remote: jQuery.format("Company name already in use")
			},
			email: {
				required: "Enter the current email address",
				email: "Enter valid email address",
				remote: "Email address already in use"
			},
			mobno: {
				required: "Enter the mobile number",
				minlength: "Enter at least 9 digit",
				maxlength: "Enter at most 15 digit"
			},
			postcode: {
				required: "Please enter postal code",
				minlength: "Please Enter Minimum 3 digits",
				//remote: jQuery.format("Enter only australian postal code")			
			},
			state_id:{
			required: "Please select state",
			},
			companydescription: {
				required:"Please enter company description"
			},
			"catname[]":{
				required: "Select Trade Category"	
			},
			"jobtype[]":{
				required: "Select Job Type"
			},
			"state_id[]":{
				required: "Select State"
			}/*,
			about_me: {
				required: "Please enter about me"
			},
			workhistory: {
				required: "Please enter work history"
			},
			qual_accred: {
				required: "Please enter qualifications & accreditations"
			}*/
			
		}
	});
	
	var validator = $("#frmMngPassword").validate({
		errorElement:'div',
		rules: {
			current_pass: {
				required:true
			},
			pass: {
				required: true,
				maxlength: 16,
				minlength:6
			},
			cpass: {
				required: true,
				maxlength: 16,
				minlength:6,
				equalTo: "#pass"
			}
		
		},
		messages: {
			current_pass: {
				required:"Please enter current password"
			},
			pass: {
				required: "Please enter new password",
				maxlength: "Enter at most 16 characters",
				minlength: "Enter at least 6 characters"
			},
			cpass: {
				required: "Please confirm new password",
				maxlength: "Enter at most 16 characters",
				minlength: "Enter at least 6 characters",
				equalTo: "Confirm password should be same as new password"
			}
		}
	});
	var validator = $("#frmMngPhoto").validate({
		errorElement:'div',
		rules: {
			photo: {
				required:true,
				accept:"jpeg|jpg|gif|png|bmp"
			}
		
		},
		messages: {
			photo: {
				required:"Please select new photo",
				accept:"Please choose jpeg / jpg / gif / png / bmp file only"
			}
		}
	});
	
	var validator = $("#frmMngWorkPhoto").validate({
		errorElement:'div',
		rules: {
			title: {
				required:true
			},
			image: {
				required:true,
				accept:"jpeg|jpg|gif|png|bmp"
			}
		
		},
		messages: {
			title: {
				required:"Please enter title"
			},
			image: {
				required:"Please select work photo",
				accept:"Please choose jpeg / jpg / gif / png / bmp file only"
			}
		}
	});
	
	var validator = $("#frmMngWorkPhotoEdit").validate({
		errorElement:'div',
		rules: {
			title: {
				required:true
			},
			image: {				
				accept:"jpeg|jpg|gif|png|bmp"
			}
		
		},
		messages: {
			title: {
				required:"Please enter title"
			},
			image: {		
				accept:"Please choose jpeg / jpg / gif / png / bmp file only"
			}
		}
	});

		
});


function addFixedRateRow()
{ 
    //document.getElementById("removeid").className='org_btn admore dis';	
	
	var AllOptions = "";
	$('#catname_1').find('option').each(function() {
	AllOptions = AllOptions + "<option value=\""+$(this).val()+"\" >"+$(this).text()+"</option>";
	});
	
	var ni = document.getElementById('feeratetable1');
	var numi = document.getElementById('feeratedivValue');
	var num = (document.getElementById("feeratedivValue").value -1)+ 2;
	numi.value = num;
		var divId = "feetr_"+num;
		var newdiv = document.createElement('div');  
		newdiv.setAttribute("id",divId);
		newdiv.innerHTML = "";
	

	
	newdiv.innerHTML = "<select name='catname[]' id='catname_"+num+"' class='select lF' onchange='showJobType();' style='width:215px;'>"+AllOptions+"</select><div style='min-height:12px; width:220px; float:left; height:auto;'></div>";
	
ni.appendChild(newdiv);
		
		document.getElementById('feerateDiv').value = num;
		document.getElementById("feeratedivValue").value = num;
		//document.getElementById('feerateDiv1').value = num1;
	
}

function removeFixedRateRow()
{
	var d = document.getElementById('feeratetable1');
	var olddiv = document.getElementById('feetr_'+document.getElementById('feerateDiv').value);
	
	d.removeChild(olddiv);
	var num = document.getElementById('feerateDiv').value-1;
	document.getElementById('feerateDiv').value = num;
	document.getElementById('feeratedivValue').value = num;
	
/*	alert(document.getElementById('feerateDiv').value)
	alert(document.getElementById('feeratedivValue').value);
	if ((document.getElementById('feeratedivValue').value-1)+2  >= document.getElementById('feerateDiv').value)
	{
		document.getElementById("removeid").className='org_btn admore disnone';		
	}
*/	
	
	
	//showJobType();

	//var num1 = document.getElementById('feerateDiv1').value-1;
	//document.getElementById('feerateDiv1').value = num1;
}